package com.lagou.client;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.InetAddress;
import java.net.Socket;

public class ClientInitClose {

    /**
     * 自定义成员变量
     */
    private Socket s;
    private ObjectOutputStream oos;
    private ObjectInputStream ois;

    public ObjectOutputStream getOos() {
        return oos;
    }

    public ObjectInputStream getOis() {
        return ois;
    }

    /**
     * 客户端初始化
     */
    public void clientInit() throws IOException {
        // 1.创建Socket类型的对象
        s = new Socket(InetAddress.getLocalHost(), 6868);
        // 2.使用输入输出流进行通信
        oos = new ObjectOutputStream(s.getOutputStream());
        ois = new ObjectInputStream(s.getInputStream());
        System.out.println("连接服务器成功...");

    }
    /**
     * 客户端关闭
     */
    public void clientClose() throws IOException {
        ois.close();
        oos.close();
        s.close();
        System.out.println("客户端成功关闭...");
    }
}
